package cn.tedu.spring.scope;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试订单类
 */
public class TestOrders {
    /**
     * 测试单实列属性对象
     */
    @Test
    public void scopeTest(){
        ApplicationContext context=new ClassPathXmlApplicationContext
                ("bean-scope.xml");
        //第一次获取bean对象
        Sku sku=context.getBean("sku",Sku.class);
        System.out.println(sku);
        //第二次获取bean对象
        Sku sku2=context.getBean("sku",Sku.class);
        System.out.println(sku2);
    }
    /**
     * 测试多实列属性对象
     */
    @Test
    public void scopeTest2(){
        ApplicationContext context=new ClassPathXmlApplicationContext
                ("bean-scope.xml");
        //第一次获取bean对象
        Sku sku=context.getBean("sku2",Sku.class);
        System.out.println(sku);
        //第二次获取bean对象
        Sku sku2=context.getBean("sku2",Sku.class);
        System.out.println(sku2);
    }
}
